﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SocialPlatformSDK.Model;
using SocialPlatformSDK.Util;

namespace SocialPlatformSDK
{

    public class RenRenCodeToken : CodeToken
    {
        /// <summary>
        ///  用来换取accesstoken的授权码，有效期为10分钟
        /// </summary>
     
        public override void LoadToken(string content)
        {
            var result = OAuthHelper.GetQueryParameters(content);

            // 通过content, 初始化 Key 和 Secret
            if (result.ContainsKey("code"))
            {
                this.Code = result["code"];
            }
          
        }
    }


    public class RenRenAccessToken : AccessToken
    {

        public override void LoadToken(string content)
        {
            var jo = JObject.Parse(content);
            this.AccesssToken = jo["access_token"].ToString();
            this.RefleshToken = jo["refresh_token"].ToString();
            this.ExpriesIn = jo["expires_in"].ToString();

        }
    }

      
}
